package cn.edu.answer.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.answer.dao.ClassDao;
import cn.edu.answer.po.Classes;
import cn.edu.answer.service.ClassService;
import cn.edu.answer.utils.Page;



/**
 * 班级管理
 */
@Service("classService")
@Transactional
public class ClassServiceImpl implements ClassService {
	// 声明DAO属性并注入
	@Autowired
	private ClassDao classDao;
	// 班级信息列表
	public Page<Classes> findClassList(Integer page, Integer rows) {
		// 创建班级对象
		Classes classes = new Classes();

		// 当前页
		classes.setStart((page-1) * rows) ;
		// 每页数
		classes.setRows(rows);
		// 查询班级列表
		List<Classes> classs = 
                            classDao.selectClassList(classes);
		// 查询班级列表总记录数
		Integer count = classDao.selectClassListCount(classes);
		// 创建Page返回对象
		Page<Classes> result = new Page<>();
		result.setPage(page);
		result.setRows(classs);
		result.setSize(rows);
		result.setTotal(count);
		return result;
	}
	
	@Override
	public int deleteClass(String classid) {
		// TODO Auto-generated method stub
		return classDao.deleteClass(classid);
	}

	@Override
	public int createclass(Classes classes) {
		// TODO Auto-generated method stub
		return classDao.createClass(classes);
	}

	@Override
	public Classes getClassById(String classid) {
		// TODO Auto-generated method stub
		return classDao.getClassById(classid);
	}

	@Override
	public int updateClass(Classes classes) {
		// TODO Auto-generated method stub
		return classDao.updateClass(classes);
	}
	
	
	
}
